package utils

import (
	"fmt"
	"time"
)

func GetMonthStartEnd(t time.Time) (time.Time, time.Time) {
	monthStartDay := t.AddDate(0, 0, -t.Day()+1)
	monthStartTime := time.Date(monthStartDay.Year(), monthStartDay.Month(), monthStartDay.Day(), 0, 0, 0, 0, t.Location())
	monthEndDay := monthStartTime.AddDate(0, 1, -1)
	monthEndTime := time.Date(monthEndDay.Year(), monthEndDay.Month(), monthEndDay.Day(), 23, 59, 59, 0, t.Location())
	return monthStartTime, monthEndTime
}

func Inttime(val string) (int64, int64) {

	stringTime := val + "-01 16:40:41"
	timeLayout := "2006-01-02 15:04:05"  //转化所需模板
	loc, _ := time.LoadLocation("Local")    //获取时区
	tmp, _ := time.ParseInLocation(timeLayout, stringTime, loc)
	year, month, _ := tmp.Date()
	thisMonth := time.Date(year, month, 1, 0, 0, 0, 0, time.Local)
	fmt.Println(thisMonth)
	start := thisMonth.AddDate(0, 0, 0).Unix()
	end := thisMonth.AddDate(0, 1, -1).Unix()
	return start,end
}